Socket
Socket
Sign inDemoInstall

@nodeutils/defaults-deep

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nodeutils/defaults-deep

Like lodash's _.defaultsDeep, but with array preservation


Version published
Weekly downloads
243
decreased by-34.68%
Maintainers
1
Weekly downloads
 
Created
Source

defaults-deep

An individual component of the [nodeutils package]

Similar to lodash's defaultsDeep, but without mutating the source object, and no merging of arrays.

Installation

Install the package via npm:

$ npm install @nodeutils/defaults-deep --save

Usage

Arguments
  1. [sources] (...Object): The source objects. Provide 2 or more, in descending order of importance
Returns

(Object): Returns the merged objects

Example
var defaultsDeep = require('@nodeutils/defaults-deep');

var objectA = { bar: { biz: { net: 'txi', qox: 'fuc' } }, qux: ['baz'] };
var objectB = { bar: { biz: { net: 'qux'} }, qux: ['biz', 'ban'] };
var objectC = { bar: { biz: { net: 'qux', lee: 'sox' } }, qux: ['biz', 'rep'], foo: 'bar' };

defaultsDeep(objectA, objectB, objectC);
// => { bar: { biz: { net: 'qux', qox: 'fuc', lee: 'sox' } }, qux: ['baz'], foo: 'bar' }

###How Incredibly simple:

"use strict";
const _ = require("lodash");
module.exports = function () {
    let output = {};
    _.toArray(arguments).reverse().forEach(item=> {
        _.mergeWith(output, item, (objectValue, sourceValue) => {
            return _.isArray(sourceValue) ? sourceValue : undefined;
        });
    });
    return output;
};

Keywords

FAQs

Package last updated on 06 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc